package com.laundry.vo;

import com.laundry.entity.Order;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class OrderVO {
    private Long id;
    private String orderNo;
    private Long userId;
    private String username; // 用户名
    
    private Long serviceTypeId;
    private String serviceTypeName; // 服务类型名称
    private String serviceTypes;    // 与前端兼容
    
    private Long clothesTypeId;
    private String clothesTypeName; // 衣物类型名称
    private String clothesTypes;    // 与前端兼容
    
    private Integer quantity;
    private BigDecimal totalAmount;
    private String pickupAddress;
    private String deliveryAddress;
    private Date pickupTime;
    private Date deliveryTime;
    private Integer status;
    private String statusText; // 状态文本描述
    private Integer paymentMethod;
    private Date paymentTime;
    private String remark;
    private Date createTime;
    private Date updateTime;
    
    // 将Order实体转为VO对象的方法
    public static OrderVO fromEntity(Order order) {
        if (order == null) {
            return null;
        }
        
        OrderVO vo = new OrderVO();
        vo.setId(order.getId());
        vo.setOrderNo(order.getOrderNo());
        vo.setUserId(order.getUserId());
        vo.setServiceTypeId(order.getServiceTypeId());
        vo.setClothesTypeId(order.getClothesTypeId());
        vo.setQuantity(order.getQuantity());
        vo.setTotalAmount(order.getTotalAmount());
        vo.setPickupAddress(order.getPickupAddress());
        vo.setDeliveryAddress(order.getDeliveryAddress());
        vo.setPickupTime(order.getPickupTime());
        vo.setDeliveryTime(order.getDeliveryTime());
        vo.setStatus(order.getStatus());
        vo.setPaymentMethod(Integer.valueOf(order.getPaymentMethod()));
        vo.setPaymentTime(order.getPaymentTime());
        vo.setRemark(order.getRemark());
        vo.setCreateTime(order.getCreateTime());
        vo.setUpdateTime(order.getUpdateTime());
        
        // 设置状态文本
        switch (order.getStatus()) {
            case 0:
                vo.setStatusText("待支付");
                break;
            case 1:
                vo.setStatusText("已支付待取件");
                break;
            case 2:
                vo.setStatusText("洗涤中");
                break;
            case 3:
                vo.setStatusText("已完成");
                break;
            case 4:
                vo.setStatusText("已取消");
                break;
            default:
                vo.setStatusText("未知状态");
        }
        
        return vo;
    }
} 